def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

def closest_prime_number(num):
    if len(num) != 3 or not num.isdigit():
        print("Wrong input")
        return
    
    word_to_num = {"zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9}
    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    number = word_to_num.get(num, None)
    if number is None:
        print("Wrong input")
        return

    closest_prime = number
    if is_prime(number):
        print(number)
        return

    lower_prime = number
    upper_prime = number
    while True:
        lower_prime -= 1
        upper_prime += 1
        if is_prime(lower_prime):
            closest_prime = lower_prime
            break
        if is_prime(upper_prime):
            closest_prime = upper_prime
            break

    print(closest_prime)

words = input().strip().split()
num = " ".join(words)
closest_prime_number(num)
